{% extends "submit/submit_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% block title %}Confirm submission of {{ submission.name }}{% endblock %}
{% block submit_content %}
    {% origin %}
    <h2>Confirm submission of {{ submission.name }}</h2>
    {% if submission.state_id != "auth" and submission.state_id != "aut-appr" %}
        {% if submission.state_id == "posted" %}
            <p class="alert alert-warning my-3">
                The submission has already been posted. See the
                <a href="{% url "ietf.doc.views_doc.document_main" name=submission.name %}">Internet-Draft here</a>.
            </p>
        {% else %}
            <div class="alert alert-info my-3">
                <p>
                    The submission is not in a state where it can be confirmed.
                </p>
                <p class="mb-0">
                    Go to the
                    <a href="{% url "ietf.submit.views.submission_status" submission_id=submission.pk %}">status page</a>
                    to see what has happened to it.
                </p>
            </div>
        {% endif %}
    {% else %}
        {% if not key_matched %}
            <div class="alert alert-danger my-3">
                <p class="error">
                    Incorrect authorization key.
                </p>
                <p class="mb-0">
                    Double-check the link you followed. If everything fails, you can go to
                    the
                    <a href="{% url "ietf.submit.views.submission_status" submission_id=submission.pk %}">status page</a>,
                    cancel the submission and try again.
                </p>
            </div>
        {% else %}
            <div class="alert alert-success my-3">
                <p>
                    Authorization key accepted.
                </p>
                <p>
                    Go to the
                    <a href="{% url "ietf.submit.views.submission_status" submission_id=submission.pk %}">status page</a>
                    for submission details and links to the files which will be posted.
                </p>
                <p class="mb-0">
                    Please press the button below to finish posting of
                    <b>{{ submission.name }}-{{ submission.rev }}</b>.
                </p>
            </div>
            <form id="confirm-submission" method="post">
                {% csrf_token %}
                <button class="btn btn-primary" type="submit" name="action" value="confirm">
                    Confirm submission &amp; post I-D
                </button>
                <button class="btn btn-danger"  type="submit" name="action" value="cancel">Cancel submission</button>
            </form>
        {% endif %}
    {% endif %}
{% endblock %}
{% block js %}
    <script>
        $(function () {
            $("form.confirm-submission").on("submit", function() {
                if (this.submittedAlready)
                return false;
                else
                this.submittedAlready = true;
            });
        });
    </script>
{% endblock %}